<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Admin\Model;
use Think\Model;

class FileModel extends AdminModel {
	
	function DeleteFile(){
		if(IsPost('Delete') && $ids=GetCheckBox($_POST['checkbox'])){
			
		}elseif(!IsPost('Delete') && $ids=intval($_GET['id'])){

		}else{
			return array('status'=>false,'message'=>'对不起，请选择ID操作!');
		}	
		
		$list=$this->where(" fid IN($ids) ")->select();

		if(!empty($list)){
			foreach($list as $file){
				if(!empty($file['fid'])){
					$id=$file['fid'];
					$this->token(false)->where(" fid=$id ")->delete();
					DelFile(FOXPHP_PATH.'/'.$file['filepath']);
					if(!empty($file['thumb'])){
						DelFile(FOXPHP_PATH.'/'.$file['thumb']);
					}
					if(!empty($file['thumbcut'])){
						DelFile(FOXPHP_PATH.'/'.$file['thumbcut']);
					}
				}
			}
		}
		
		return array('message'=>'删除成功!');
	}
}

?>